<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
<meta charset="UTF-8">
<title>梦想人力资源管理系统</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/admin/css/font.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/admin/css/xadmin.css">
<script type="text/javascript"
	src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/admin/lib/layui/layui.js"
	charset="utf-8"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/admin/js/xadmin.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/admin/js/cookie.js"></script>
<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
<!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
<style type="text/css">
.layui-form-selectup dl {
	top: 42px;
	bottom: unset;
}
</style>
</head>

<body>
	<div class="x-body">
		<form class="layui-form">
			<input type = "hidden" name = "id" value = "<s:property value="depart.id" />">
			<div class="layui-form-item">
				<label for="L_dname" class="layui-form-label"> <span
					class="x-red">*</span>部门名称
				</label>
				<div class="layui-input-inline">
					<input type="text" id="L_dname" name="dname" required="" value="<s:property value="depart.dname" />"
						lay-verify="required" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="L_principal" class="layui-form-label"> <span
					class="x-red">*</span>部门负责人
				</label>
				<div class="layui-input-inline">
					<input type="text" id="L_principal" name="principal" required="" value="<s:property value="depart.principal" />"
						lay-verify="required" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item layui-form-text">
		    	<label for="L_depint" class="layui-form-label">部门介绍</label>
			    <div class="layui-input-block">
			      <textarea id="L_depint" name="depint" placeholder="请输入内容" class="layui-textarea" ><s:property value="depart.depint" /></textarea>
			    </div>
 			</div>		
			<div class="layui-form-item">
				<label for="L_repass" class="layui-form-label"> </label>
				<button class="layui-btn" lay-filter="add" lay-submit="">
					提交</button>
			</div>
		</form>
	</div>
	<script>
		layui.use([ 'form', 'layer' ], function() {
			$ = layui.jquery;
			var form = layui.form, layer = layui.layer;

			//监听提交
			form.on('submit(add)', function(data) {
				console.log(data.field);
				//发异步，把数据提交给java
				$.ajax({
					url : "${pageContext.request.contextPath}/updateDepart",
					data : {
						id : data.field.id,
						dname : data.field.dname,
						principal : data.field.principal,
						depint : data.field.depint
					},
					dataType : 'json', // 服务器返回json格式数据
					type : 'post', // HTTP请求类型
					timeout : 10000, // 超时时间设置为10秒；
					success : function(data) {
						if (data.isUpdate == true) {
							layer.alert("修改成功", {
								icon : 1
							}, function() {
								//关闭当前frame
								x_admin_close();

								// 可以对父窗口进行刷新 
								x_admin_father_reload();
							});
						} else {
							layer.alert(data.isUpdate, {
								icon : 2
							})
						}
					},
					error : function(xhr, type, errorThrown) {
						layer.alert("服务器挂了，稍后试试吧！", {
							icon : 5
						})
					}
				});

				return false;
			});

		});
	</script>
</body>

</html>